var a = getApp();

Page({
    data: {
        teamId: "",
        data: []
    },
    loadData: function() {
        var t = this;
        a.network.post({
            url: a.url.teamAdminList,
            params: {
                id: t.data.teamId
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(o) {
                1 == o.data.result ? t.setData({
                    data: o.data.data.users
                }) : a.util.showToast(o.data.message);
            },
            fail: function() {
                a.util.showToast("加载失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    clickSet: function(t) {
        var o = t.currentTarget.dataset.token, n = this;
        a.network.post({
            url: a.url.addTeamAdmin,
            params: {
                id: n.data.teamId,
                adminAccessToken: o
            },
            before: function() {
                wx.showNavigationBarLoading(), wx.showLoading({
                    title: "正在设置"
                });
            },
            success: function(t) {
                wx.hideLoading(), a.util.showToast(t.data.message), 1 == t.data.result && n.loadData();
            },
            fail: function() {
                wx.hideLoading(), a.util.showToast("设置失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    clickCancel: function(t) {
        var o = t.currentTarget.dataset.token, n = this;
        a.network.post({
            url: a.url.cancelTeamAdmin,
            params: {
                id: n.data.teamId,
                adminAccessToken: o
            },
            before: function() {
                wx.showNavigationBarLoading(), wx.showLoading({
                    title: "正在取消"
                });
            },
            success: function(t) {
                wx.hideLoading(), a.util.showToast(t.data.message), 1 == t.data.result && n.loadData();
            },
            fail: function() {
                wx.hideLoading(), a.util.showToast("取消失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    onLoad: function(a) {
        this.setData({
            teamId: a.teamId
        }), this.loadData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});